package com.study.userserviceprovider.controller;

import com.study.clients.OrderFeignClient;
import com.study.entity.OrderDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class HystrixFeignController {

    @Autowired(required = false)
    private OrderFeignClient orderFeignClient;

    @GetMapping("/hystrix/feign/order")
    public String queryOrder(){
        return orderFeignClient.getAllOrders();
    }

    @PostMapping("/hystrix/feign/order")
    public String insertOrder(){
        OrderDto orderDto=new OrderDto();
        orderDto.setOrderId("GP0001");
        return orderFeignClient.insertOrders(orderDto)>0?"SUCCESS":"FAILED";
    }

    /*@GetMapping("/hystrix/test")
    public String test(){

    }*/


}
